package com.css.fxfzfxqh.modules.earthquakeRiskAssessmentZoningReport.repository;

import com.css.fxfzfxqh.modules.earthquakeRiskAssessmentZoningReport.model.entity.FxqhAssessReportRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
import org.springframework.jdbc.core.namedparam.SqlParameterSourceUtils;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class FxqhAssessReportRecordRepository {
    @Autowired
    private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    public void batchSave(List<FxqhAssessReportRecord> fxqhAssessReportRecords) {
        SqlParameterSource[] beanSources = SqlParameterSourceUtils.createBatch(fxqhAssessReportRecords.toArray());
        String sql = "INSERT INTO fxqh_assess_report_record(id, report_id, record_id) values(:id, :reportId, :recordId)";
        namedParameterJdbcTemplate.batchUpdate(sql, beanSources);
    }
}
